<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<%= javascript_include_tag "calendar" %>
<script language="JavaScript" type="text/JavaScript">
        function checkPWD(flag){
                if (flag) {
                        if ($("account_password").value != "")
                        {
                                if ($("account_password").value.length<5 || $("account_password").value.length>10)
                                {
                                        $("pwd").innerText = "密码必须为5到10个字符";
                                        $("pwd").style.display = "block";
                                        return false;
                                }
                                else if ($("account_password").value != "" && amountCheck($("account_password").value) )
                                {
                                        $("pwd").innerText = "密码安全程度：弱";
                                        $("pwd").style.display = "block";
                                        return true;      
                                }
                                else return true;
                        }
                        else return true;
                }
                else {
                        $("pwd").style.display = "none";
                }
        }
        function checkPWD1(flag){
                if (flag) {
                        if ($("account_password").value != "" && $("account_password").value != $("account_password_confirmation").value )
                        {
                                $("pwdConfirm").innerText = "两次输入密码不一致";
                                $("pwdConfirm").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("pwdConfirm").style.display = "none";
                }
        }
        function checkName(flag){
                if (flag) {
                        if ($("employee_name").value == "")
                        {
                                $("id_name").innerText = "姓名不可为空";
                                $("id_name").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_name").style.display = "none";
                }
        }
        function checkMail(flag){
                if (flag) {
                        if ($("employee_email").value != "" && ! checkEmail($("employee_email").value))
                        {
                                $("id_email").innerText = "邮件地址不正确";
                                $("id_email").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_email").style.display = "none";
                }
        }

        function checkForm(){
                return checkName(true) && checkPWD(true) && checkPWD1(true) && checkMail(true);
        }
</script>
<h1>员工管理 - <span id="secondHeading"><%='修改个人信息' if 'self'.eql? @type%><%='修改员工信息' if !'self'.eql? @type%></span></h1>
<%=form_tag({},:multipart => true, :id => "input-form")%>
<TABLE border="0" id="INPUT_TABLE">
	<TR>
		<TD colspan="2">
			<% if @flash[:notice] -%>
			<div id="notice"><%= @flash[:notice] %></div>
			<% end -%>
		</TD>
	</TR>
        <TR>
	<input type="hidden" name="employee_id" value="<%=@employee_id%>"/>
	<input type="hidden" name="type" value="<%=@type%>"/>
        <TD>姓名：</TD>
		<TD><input type="text" name="name" id="employee_name" value="<%=@employee.name%>" maxlength="20" onfocus="checkName(false)" onblur="checkName(true)" />          <em>*</em> <div class="redNsg" id="id_name" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>密码：</TD>
                <TD><%= password_field "account", "password", :onfocus => "checkPWD(false)", :onblur => "checkPWD(true)", :maxlength => "20" %> <div class="redNsg" id="pwd" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>确认密码：</TD>
                <TD><%= password_field "account", "password_confirmation", :onfocus => "checkPWD1(false)", :onblur => "checkPWD1(true)", :maxlength => "20" %> <div class="redNsg" id="pwdConfirm" style="display:block;"></div></TD>
	</TR>
	<%if !'self'.eql? @type%>
	<TR>
		<TD class="b">所属角色：</TD>
		<TD><select name="role_id">
		<% @roles.each do |role| %>
		<option value='<%=role.id%>'
		<%= ' selected' if role.id == @employee.account.role_id%>>
		<%=role.name%> </option>
		<% end %>
	</select></TD>
	</TR>
	<%else%>
	<input type="hidden" name="role_id" value="<%=@employee.account.role_id%>"%>
	<%end%>
	<TR>
		<TD>照片：</TD>
		<TD>
                <%= file_column_field "employee", "photo", :size => "20" , :readyonly => ""%>
		</TD>
	</TR>
	<TR>
		<TD>英文名：</TD>
		<TD><input type="text" name="english_name" value="<%=@employee.english_name%>" maxlength="20"/></TD>
	</TR>
    <TR>
		<TD>性别：</TD>
		<TD><select name="sex">
		<option value='0'<%= ' selected' if @employee.sex == 0%>>女</option>
		<option value='1'<%= ' selected' if @employee.sex == 1%>>男</option>
	</select></TD>
	</TR>
	<TR>
		<TD>生日：</TD>
                <TD>
                        <!-- <%=select_date(@employee.birthday_at,:use_month_numbers => true)%> -->
                        <script language=javascript>
                                var bir_Date=new dateSelector('<%= @employee.birthday_at %>');
                                bir_Date.inputID='date';
                                bir_Date.inputName='date';
                                bir_Date.display();
                        </script>
                </TD>
	</TR>
	<TR>
		<TD>婚姻状况：</TD>
                <TD><input id="married_id" name="married" type="hidden" value="<%=@employee.married%>"><input name="married_chk" type="checkbox" value="1" <%=' checked' if @employee.married==1%> onclick="$('married_id').value = ($('married_id').value == 1) ? 0:1;"/></TD>
	</TR>
	<TR>
		<TD>固定电话：</TD>
		<TD><input type="text" name="phone" value="<%=@employee.phone%>" maxlength="20"/></TD>
	</TR>
    <TR>
		<TD>原籍电话：</TD>
		<TD><input type="text" name="ori_phone" value="<%=@employee.ori_phone%>" maxlength="20"/></TD>
	</TR>
    <TR>
		<TD>手机：</TD>
		<TD><input type="text" name="mobile" value="<%=@employee.mobile%>" maxlength="20"/></TD>
	</TR>
	<TR>
		<TD >小灵通：</TD>
		<TD><input type="text" name="lingtong" value="<%=@employee.lingtong%>" maxlength="20"/></TD>
	</TR>
  	<TR>
		<TD>电子邮件：</TD>
		<TD><input type="text" name="email" id="employee_email" value="<%=@employee.email%>" maxlength="20" onfocus="checkMail(false)" onblur="checkMail(true)" /> <div class="redNsg" id="id_email" style="display:none;"></div></TD>
	</TR>
    <TR>
		<TD>备注：</TD>
		<TD><textarea cols="50" name="resume" rows="5"><%=@employee.resume%></textarea></TD>
	</TR>
	<TR>
		<TD colspan="2" align="right"><b>状态:</b>
    <%if @employee.state==1%><font color="green">正常</font><%elsif @employee.state==0%><font color="red">停用</font><%end%>
  <input type="submit" value="修改" class="sub" onclick="javascript:return checkForm();">&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></TD>
	</TR>
 </table>
 <p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项：<br/>二、密码长度6～20位，由英文字母a～z (区分大小写)，数字0～9，特殊字符组成。
 </p>
 <%=end_form_tag%>
